package com.example.experiment_5;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class MySQLiteOpenHelper extends SQLiteOpenHelper {

    /**
     * 构造方法
     * @param context 上下文实例
     */
    public MySQLiteOpenHelper(Context context) {
        super(context, "contact.db", null, 1);
    }

    // 数据库第一次执行时调用该方法(建表语句)
    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        sqLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS contact(" +
                "_id INTEGER PRIMARY KEY AUTOINCREMENT," +
                "name VARCHAR(20)," +
                "phone VARCHAR(20))");
    }

    // 当数据库版本号增加即数据库更新时调用
    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {

    }

}
